package manager.match.basic.type;

import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnore;

import manager.match.basic.state.MatchState;

public class MatchInfo {

	private int matchId = generateMatchId();
	private String songId = "";
	private int state = MatchState.WAIT_FOR_READY;
	private List<EnrollPlayerInfo> playerList = null;
	private List<MatchScore> scoreList = new ArrayList<MatchScore>();

	private int winnerIndex = -1;

	private long startTime = System.currentTimeMillis();
	@JsonIgnore private boolean toBeRemoved = false;
	public boolean isToBeRemoved() {
		return toBeRemoved;
	}

	public void setToBeRemoved(boolean toBeRemoved) {
		this.toBeRemoved = toBeRemoved;
	}
	public int getWinnerIndex() {
		return winnerIndex;
	}

	public void setWinnerIndex(int winnerIndex) {
		this.winnerIndex = winnerIndex;
	}

	public void stateChanged(){
		setStartTime(System.currentTimeMillis());
		
	}
	
	public int getMatchId() {
		return matchId;
	}
	public void setMatchId(int matchId) {
		this.matchId = matchId;
	}
	public int getState() {
		return state;
	}
	public void setState(int state) {
		this.state = state;
		System.out.println("set match " + matchId + " to state " + state);
		stateChanged();
	}
	public List<EnrollPlayerInfo> getPlayerList() {
		return playerList;
	}
	public void setPlayerList(List<EnrollPlayerInfo> playerList) {
		this.playerList = playerList;
	}
	public String getSongId() {
		return songId;
	}
	public void setSongId(String songId) {
		this.songId = songId;
	}
	
	private static int maxMatchId = 0;
	private int generateMatchId(){
		maxMatchId ++;
		return maxMatchId;
	}

	public long getStartTime() {
		return startTime;
	}

	public void setStartTime(long startTime) {
		this.startTime = startTime;
	}

	public List<MatchScore> getScoreList() {
		return scoreList;
	}

	public void setScoreList(List<MatchScore> scoreList) {
		this.scoreList = scoreList;
	}
}
